#include<cstdio>
#include<algorithm>
using namespace std;
#define LL long long
const int maxn=100001;
int a[maxn];
LL sum[maxn];
struct node
{
	int h,r;
	bool friend operator<(node a,node b)
	{
		if(a.r==b.r)
			return a.h<b.h;
		return a.r<b.r;
	}
}R[maxn];

int main()
{
	int n,c;
	while(scanf("%d%d",&c,&n))
	{
		int left,right;
		if(c==0&&n==0)break;
		sum[0]=0;
		bool find=false;
		for(int i=1;i<=n;i++)
		{
			scanf("%d",&a[i]);
			sum[i]=sum[i-1]+a[i];
			R[i].h=i;
			R[i].r=sum[i]%c;
			if(R[i].r==0){left=1;right=i;find=true;}
		}
		if(!find)
		{
			sort(R+1,R+n+1);
			for(int i=1;i<n;i++)
				if(R[i].r==R[i+1].r)
				{
					left=R[i].h+1;
					right=R[i+1].h;
					break;
				}
		}

		for(int i=left;i<right;i++)
			printf("%d ",i);
		printf("%d\n",right);

	}
}
